package com.lsy.weizhi2.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.lsy.weizhi2.R;
import com.lsy.weizhi2.activity.AllWeiYou;
import com.lsy.weizhi2.config.Constants;
import com.lsy.weizhi2.utils.MyMethod;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;

/**
 * Created by 嗨哟 on 2017/3/18.
 */
public class WeiYouAdapter extends RecyclerView.Adapter<WeiYouAdapter.WeiYouHolder> {
    private Context context;
    private List<?>list;
    private LayoutInflater layoutInflater;

    public WeiYouAdapter(Context context, List<?> list) {
        this.context = context;
        this.list = list;
        layoutInflater=LayoutInflater.from(context);
    }

    @Override
    public WeiYouHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view=layoutInflater.inflate(R.layout.weiyou_item,parent,false);
        AutoUtils.autoSize(view);
        return new WeiYouHolder(view);
    }

    @Override
    public void onBindViewHolder(WeiYouHolder holder, int position) {
        holder.position=position;
        holder.weiyou_item_name.setText(Constants.weiyou[position]);
        WeiYouImageAdapter adapter=new WeiYouImageAdapter(context,null);
        holder.weiyou_item_gv.setAdapter(adapter);
    }

    @Override
    public int getItemCount() {
        return 3;
    }

    class WeiYouHolder extends RecyclerView.ViewHolder{
        int position;
        TextView weiyou_item_name,weiyou_item_all;
        GridView weiyou_item_gv;
        public WeiYouHolder(View itemView) {
            super(itemView);
            weiyou_item_name= (TextView) itemView.findViewById(R.id.weiyou_item_name);
            weiyou_item_all= (TextView) itemView.findViewById(R.id.weiyou_item_all);
            weiyou_item_gv= (GridView) itemView.findViewById(R.id.weiyou_item_gv);
            weiyou_item_all.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    String name=weiyou_item_name.getText().toString();
                    //跳转全部微友
                    MyMethod.toActivity(context, AllWeiYou.class,new String[]{"name"},new String[]{name});
                }
            });
        }
    }


}
